package com.isunland.managesystem.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.ContractList.ContractDetail;
import java.util.List;

public class ContractListAdapter extends ArrayAdapter<ContractDetail> {

  /**
   * ViewHolder class for layout.<br />
   * <br />
   * Auto-created on 2016-01-19 13:14:12 by Android Layout Finder
   * (http://www.buzzingandroid.com/tools/android-layout-finder)
   */
  private static class ViewHolder {
    public final LinearLayout rootView;
    public final TextView tvContractNumList;
    public final TextView tvContractNameList;

    private ViewHolder(LinearLayout rootView, TextView tvContractNumList,
        TextView tvContractNameList) {
      this.rootView = rootView;
      this.tvContractNumList = tvContractNumList;
      this.tvContractNameList = tvContractNameList;
    }

    public static ViewHolder create(LinearLayout rootView) {
      TextView tvContractNumList = (TextView) rootView.findViewById(R.id.tv_contractNumList);
      TextView tvContractNameList = (TextView) rootView.findViewById(R.id.tv_contractNameList);
      return new ViewHolder(rootView, tvContractNumList, tvContractNameList);
    }
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
      View view = mInflater.inflate(R.layout.adapter_contractl_ist, parent, false);
      vh = ViewHolder.create((LinearLayout) view);
      view.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }

    ContractDetail item = getItem(position);

    vh.tvContractNumList.setText(item.getContractCode());
    vh.tvContractNameList.setText(item.getContractName());

    return vh.rootView;
  }

  private LayoutInflater mInflater;

  // Constructors
  public ContractListAdapter(Context context, List<ContractDetail> objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }

  public ContractListAdapter(Context context, ContractDetail[] objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }
}

